<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Location对象</title>
</head>
<body>

<input id="reload" type="button" value="刷新">
<input id="goBtn" type="button" value="去百度">

<script>

    // reload方法，定义一个按钮，点击刷新页面
    var reload = document.getElementById("reload");
    reload.onclick = function() {
      location.reload();
    }

    // 获取 href
    var href = location.href;
    //alert(href);

    // 点击按钮，访问百度
    var goBtn = document.getElementById("goBtn");
    goBtn.onclick = function() {
      location.href = "https://www.baidu.com";
    }

  </script>

</body>
</html>